package com.zhubayi.mapper;

import com.zhubayi.entity.Video;
import com.zhubayi.entity.vo.CategoryVideoNumVo;
import com.zhubayi.entity.vo.PubTimeVo;
import com.zhubayi.entity.vo.VideoVo;
import com.zhubayi.utils.VideoQueryConditionUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 祝八一
 */
@Repository
@Mapper
public interface VideoMapper {
    List<Video> queryAll();

    List<Video> queryByTitle(@Param("title") String title);

    Video queryById(@Param("id") Integer id);

    List<Video> queryByUserId(@Param("id") Integer id);
    List<Video> queryByCategoryId(@Param("id") Integer id);
    List<Video> queryByCategoryIdAndUserId(@Param("userId") Integer id, @Param("categoryId") Integer categoryId);

    void deleteById(@Param("id") Integer id);
    void update(Video video);
    void addViewNum(@Param("id") Integer id);

    /**
     * 点赞收藏增加
     * @param id
     */
    void addPraiseNum(@Param("id") Integer id);

    /**
     * 点赞
     * @param id
     */
    void addGreatNum(@Param("id") Integer id);
    void readuceGreatNum(@Param("id") Integer id);
    /**
     * 点赞次数减少
     * @param id
     */
    void reducePraiseNum(@Param("id") Integer id);
    List<VideoVo> getAll(@Param("categoryId") Integer categoryId, @Param("title") String title);

    List<VideoVo> queryCondition(VideoQueryConditionUtils utils);

    void addVideo(Video video);

    List<VideoVo> queryVoByUid(@Param("id") Integer id);

    List<Video> queryFavor(@Param("id") Integer id);
    List<CategoryVideoNumVo> queryCategoryVideoNum();

    List<Video> queryOrderByViewNum(@Param("num") Integer num);
    List<Video> queryOrderByPraiseNum(@Param("num") Integer num);
    //@Select("  SELECT wn_video.`pub_time`,COUNT(1) AS num FROM wn_video GROUP BY pub_time")
    List<PubTimeVo> queryPubTime();
}
